
import { getPaperDetail } from '@/api/paper'
import router from '@/router'
import { getUserInfo } from '@/api/other'

let mutation = {
    SETROUTERLIST(state,data){     //设置面包屑数据
        state.routerList = data
    },
    SETDEFAULRACTIVE(state,data){
        state.defaultActive = data;
    },
    openPaper(state, id){
        getPaperDetail(id).then(res => {
            if(res.code == 200){
                state.paper = res.data
                router.push('/student/paper')
            }
        })
    },
    closePaper(state){
        state.paper = undefined
    },
    getUserInfo(state, fn){
        if (state.userInfo) {
            fn(state.userInfo)
        }else{
            getUserInfo().then(res => {
                state.userInfo = res.data
                fn(state.userInfo)
            })
        }
    },
    setPath(state, path){
        router.push('/student/home')
        setTimeout(() => {
            router.replace(path)
        }, 300)
    },
}

export default mutation